﻿using HomagChina.Basic.CCT.Db.CCHS_Db;
using HomagChina.Basic.CCT.Tools;
using HomagGroup.Base.UI;
using Proxy;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Automation;
using LocalText = Proxy.Properties.Resources;

namespace HomagChina.CCHS.ViewModels
{
    public class BoardRepetitiousViewModel : NotifyPropertyChangedBase
    {
        InsertInfoHandle Handle_Insert;
        CommonHandle Handle_Command;
        public RelayCommand ReplaceCommand { get; }

        private string _Title;
        public string Title
        {
            get => _Title;
            set { _Title = value; OnPropertyChanged(); }
        }

        private List<BoardInfoConstruct> _List_BoardInfoModel;

        public List<BoardInfoConstruct> List_BoardInfoModel
        {
            get => _List_BoardInfoModel;
            set { _List_BoardInfoModel = value; OnPropertyChanged(); }
        }

        private bool _SelectedState = true;

        public bool SelectedState
        {
            get => _SelectedState;
            set { _SelectedState = value; OnPropertyChanged(); }
        }

        private ObservableCollection<object> _SelectedList = new ObservableCollection<object>();

        public ObservableCollection<object> SelectedList
        {
            get => _SelectedList;
            set
            {
                _SelectedList = value;
                OnPropertyChanged();
            }
        }

        Returnstructure4Boardlibrary returnstructure4Boardlibrary = new Returnstructure4Boardlibrary();

        public BoardRepetitiousViewModel(Returnstructure4Boardlibrary returnstructure)
        {
            Title = LocalText.RepetitiousInfo;
            returnstructure4Boardlibrary = returnstructure;
            Handle_Insert = new InsertInfoHandle();
            Handle_Command = new CommonHandle();
            ReplaceCommand = new RelayCommand(Repalce);
            List_BoardInfoModel = returnstructure4Boardlibrary.repetitious;
        }

        /// <summary>
        /// 替换
        /// </summary>
        public void Repalce()
        {
            _ = Handle_Insert.InsertBoardsInfo(returnstructure4Boardlibrary.repetitious, SelectedList) == true ? HomagGroup.Base.UI.Windows.MessageBox.Show(LocalText.Congratulations_information_added_successfully) : HomagGroup.Base.UI.Windows.MessageBox.Show(LocalText.Sorry_information_addition_failed_please_try_again_or_contact_administrator);
            Handle_Command.CloseDiaLog(Title);
        }
    }
}
